<template>
	<div>
		<form @submit.prevent="nextStep">
			<div class="carEditorSubmit">
				<button class="button button-icon" slot="right" type="submit" style="color: #fff; font-size: 13px;">确定</button>
			</div>
			<div class="page has-navbar has-tabbar" v-nav="{title: '车辆特卖', showBackButton: true}">
				<div class="page-content padding-top reserve-margin">
					<div class="car-editor">

						<div class="reserve">
							<input type="number" name="carId" v-model="routerParams.carId" style="display: none;" />
							<list>
								<item>
									<div class="car-enitor-tr">
										<div class="car-editor-name">特卖价格</div>
										<div class="car-editor-input"><input type="number" step="0.01" placeholder="请填写特卖金额" name="carRetailPrice" v-model="routerParams.carRetailPrice" /></div>
										<div class="car-editor-right">万元</div>
									</div>
								</item>
								<item>
									<div class="car-enitor-tr on">
										<textarea placeholder="请输入特卖描述" v-model="routerParams.carSellingPointDesc" name="carSellingPointDesc" ></textarea>
									</div>
								</item>
							</list>
						</div>

					</div>
				</div>
			</div>
		</form>
		
	</div>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		computed: {
			routerParams() {
				return this.$route.query.params
			},
			userSession() {
				return sess.get('userSession')
			}

		},
		methods: {
			nextStep(event) {
				var _this = this
				$dialog.confirm({
					// 标题					
					title: '提示',
					content: '是否提交修改',
					// 取消按钮文本
					cancelText: '取消',
					// 确定按钮文本
					okText: '提交'
				}).then((res) => {
					if(res) {
						var formData = new FormData(event.target);
						window.axios.post(baseUrl + '/controller/car/updateCar', formData)
						.then((data) => {
							if(data){
								setTimeout(()=>{
									$toast.show('修改成功', 2000)
									setTimeout(()=>{
										this.$router.go(-1)
									},2000)
								},400)
							}
						})
					}
				})
			},
			
			userIs() {
				if(!(this.userSession)) {
					$toast.show('请登录', 2000).then(() => {

					})
					setTimeout(() => {
						this.$router.push({
							path: '/'
						})
					},1000)
				}
				if(!(this.$route.query.params.carId)) {
					$toast.show('获取失败', 2000).then(() => {

					})
					setTimeout(() => {
						this.$router.go(-1)
					}, 1000)

				}
			}
		},
		mounted() {
			this.userIs()
//			$toast.show('修改成功', 2000)
		}

	}
</script>